<%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-12-09
  Time: 17:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>增加课程信息</title>
    <link rel="stylesheet" type="text/css" href="/form.css" />
</head>
<body>
<form action="/course/add" class="container">

    <h2>添加课程信息</h2>

    <div class="form-group">

        <label for="name">课程名:</label>

        <input type="text" name="name" id="name" class="form-control">

    </div>

    <div class="form-group">

        <label for="teacher">授课教师:</label>

        <input type="text" name="teacher" id="teacher" class="form-control">

    </div>

    <div class="form-group">

        <label for="capacity">容量:</label>

        <input type="number" name="capacity" id="capacity" class="form-control">

    </div>

    <div class="form-group">

        <label for="s_time">开始时间:</label>

        <input type="datetime-local" min="00:00" max="23:59" name="startTime0" id="s_time" class="form-control">

    </div>

    <div class="form-group">

        <label for="e_time">结束时间:</label>

        <input type="datetime-local" min="00:00" max="23:59" name="endTime0" id="e_time" class="form-control">

    </div>
    <div class="form-group">

        <label for="bz">课程说明:</label>

        <input name="bz" id="bz" class="form-control">

    </div>
    <div class="form-group">

        <label for="bz">学分:</label>

        <input name="xf" id="xf" class="form-control">

    </div>

    <div style="text-align: center">

        <button type="submit" id="toAdd" style="width: 100px;height: 50px;background-color: #fff" class="btn btn-primary">添加</button>

    </div>

</form>

</body>
<script>
    let toAdd = document.getElementById("toAdd");
    toAdd.addEventListener("click",(evt)=>{
        let name_str=document.getElementById("name").value;
        if(name_str===null||name_str===""){
            alert("请输入课程名");
            evt.preventDefault();
            return;
        }
        let teacher_str=document.getElementById("teacher").value;
        if(teacher_str===null||teacher_str===""){
            alert("请输入授课教师名字");
            evt.preventDefault();
            return;
        }
        let capacity_str=document.getElementById("capacity").value;
        if(capacity_str===null||capacity_str===""){
            alert("请输入容量");
            evt.preventDefault();
            return;
        }
        let bz_str=document.getElementById("bz").value;
        if(bz_str===null||bz_str===""){
            alert("请输入课程说明");
            evt.preventDefault();
            return;
        }
        let xf_str=document.getElementById("xf").value;
        if(xf_str===null||xf_str===""){
            alert("请输入课程学分");
            evt.preventDefault();
            return;
        }
    })
</script>
</html>
